package com.atguigu.auth.service.Impl;

import com.atguigu.auth.mapper.SysUserMapper;
import com.atguigu.auth.service.SysUserService;
import com.atguigu.model.system.SysUser;
import com.atguigu.security.custom.LoginUserInfoHelper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 12646
 * @description 针对表【sys_user(用户表)】的数据库操作Service实现
 * @createDate 2023-11-13 22:58:37
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
  // @Autowired
  // private SysDeptService sysDeptService;
  // @Autowired
  // private SysPostService sysPostService;
  @Autowired
  private SysUserMapper sysUserMapper;
  
  @Override
  public SysUser getByUsername(String username) {
    return this.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, username));
  }
  
  @Override
  public Map<String, Object> getCurrentUser() {
    SysUser sysUser = sysUserMapper.selectById(LoginUserInfoHelper.getUserId());
    // SysDept sysDept = sysDeptService.getById(sysUser.getDeptId());
    // SysPost sysPost = sysPostService.getById(sysUser.getPostId());
    Map<String, Object> map = new HashMap<>();
    map.put("name", sysUser.getName());
    map.put("phone", sysUser.getPhone());
    // map.put("deptName", sysDept.getName());
    // map.put("postName", sysPost.getName());
    System.out.println(sysUser);
    return map;
  }
}




